using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace SpoonCore.Message.Stun
{
	class StunMessage : IMessage
	{
		public enum StatusValue : byte { Ok, Faild }
		public enum TypeValue : byte { Request, Response }
		public enum SortValue : byte { Ping, Register, Peer }

		private StatusValue _status = StatusValue.Ok;
		private TypeValue _type = TypeValue.Request;
		private SortValue _sort = SortValue.Ping;

		public int MsgId
		{
			get { return 10; }
		}

		public StunMessage()
		{ }

		public StunMessage(SortValue sort, TypeValue type)
		{
			_sort = sort;
			_type = type;
		}

		public byte[] GetBytes()
		{
			MemoryStream stream = new MemoryStream();
			BinaryWriter bw = new BinaryWriter(stream);

			bw.Write((byte)_status);
			bw.Write((byte)_type);
			bw.Write((byte)_sort);

			return stream.ToArray();
		}

		public void SetBytes(SpoonClient client, BinaryReader br)
		{
			_status = (StatusValue)br.ReadByte();
			_type = (TypeValue)br.ReadByte();
			_sort = (SortValue)br.ReadByte();

			if (_sort == SortValue.Register)
			{
				
			}
		}

		public IMessage Clone()
		{
			return new StunMessage();
		}

		public Info.MessageInfo Info
		{
			get { return null; }
			set { }
		}
	}
}
